libotutil: Avoid infinite recursion during error unwinding
authorSimon McVittie <smcv@collabora.com>
Fri, 28 Jan 2022 11:08:00 +0000 (11:08 +0000)
committerSimon McVittie <smcv@collabora.com>
Fri, 28 Jan 2022 11:08:00 +0000 (11:08 +0000)
When we clean up from an error, for example copy_file_range() failing
while we generate a static delta (perhaps caused by
https://gitlab.gnome.org/GNOME/libglnx/-/issues/3 or by a
genuine write error), we might free a variant builder that has a
non-null parent. Previously, this caused infinite recursion and a stack
overflow, repeatedly freeing the same object, but Luca Bruno suggested
that the intention here appears to have been to free the parent object.

Partially resolves https://github.com/ostreedev/ostree/issues/2525
(the other bug reported in that issue needs to be resolved by updating
libglnx to a version where libglnx#3 has been fixed).

Signed-off-by: Simon McVittie <smcv@collabora.com>
src/libotutil/ot-variant-builder.c

index 754b932337974e04c637ed308eca9298bd562bb5..4d3dcbe5cd671c9e101726f931005ab0524a432f 100644 (file)
@@ -830,7 +830,7 @@ static void
 ot_variant_builder_info_free (OtVariantBuilderInfo *info)
 {
   if (info->parent)
-    ot_variant_builder_info_free (info);
+    ot_variant_builder_info_free (info->parent);
 
   g_variant_type_free (info->type);
   g_array_unref (info->child_ends);